package cevent.source.cloudcenter.business.controller.client;/**
 * Created by Cevent on 2021/7/21.
 */

import cevent.source.cloudcenter.server.dto.PageSelectDto;
import cevent.source.cloudcenter.server.dto.ResponseDataDto;
import cevent.source.cloudcenter.server.service.ArticleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author cevent
 * @description 客户端文章接口
 * @date 2021/7/21 22:15
 */
@RestController
@RequestMapping("/client/article")
public class ClientAtticleController {
    private static final Logger LOG= LoggerFactory.getLogger(ClientProductController.class);
    public static final String BUSINESS_NAME="客户端Article模块";

    @Autowired
    ArticleService articleService;
    //根据typeId获取新闻列表
    @PostMapping("/page/list")
    public ResponseDataDto getArticlePageList(@RequestBody PageSelectDto pageSelectDto){
        ResponseDataDto responseData=new ResponseDataDto();
        if(pageSelectDto.getTypeId()!=null){
            articleService.getArticlePageList(pageSelectDto);
        }else{
            articleService.getArticleDtoList(pageSelectDto);
        }
        responseData.setResponseData(pageSelectDto);
        return responseData;
    }
    //根据首页推荐，进行首页新闻回显
    @GetMapping("/index/list")
    public ResponseDataDto getArticleIndexList(){
        ResponseDataDto responseData=new ResponseDataDto();
        responseData.setResponseData(articleService.getArticleIndexList());
        return responseData;
    }
    //新闻中心页面的封面图
    @GetMapping("/picCover")
    public ResponseDataDto getArticlePicCover(){
        ResponseDataDto responseData=new ResponseDataDto();
        responseData.setResponseData(articleService.getArticlePicCover());
        return responseData;
    }

    //获取previous/next文章集合
    @PostMapping("/previous/{uniId}")
    public ResponseDataDto getArticlePrevious(@PathVariable String uniId){
        ResponseDataDto responseData=new ResponseDataDto();
        responseData.setResponseData(articleService.getArticlePrevious(uniId));
        return responseData;
    }
    @PostMapping("/next/{uniId}")
    public ResponseDataDto getArticleNext(@PathVariable String uniId){
        ResponseDataDto responseData=new ResponseDataDto();
        responseData.setResponseData(articleService.getArticleNext(uniId));
        return responseData;
    }
}
